package com.xian.im.web.modules.tenant;

import com.xian.im.common.model.dto.OrganizationDto;
import com.xian.im.common.model.from.OrganizationFrom;
import com.xian.im.common.result.RestResult;
import com.xian.im.common.result.RestResultBuilder;
import com.xian.im.modules.im.core.IOrganizationCoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;


/**
 * 
 *
 * @author xlr
 * @email 
 * @date 2021-01-18 19:11:56
 */
@RestController
@RequestMapping("im/org")
@Api(value = "机构操作API", tags = {"机构操作"})
public class TenantController {

    @Autowired
    private IOrganizationCoreService organizationCoreService;

    @ApiOperation(value = "添加机构", notes = "添加机构")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    public RestResult<OrganizationDto> add(@RequestBody OrganizationFrom from){
        OrganizationDto save = organizationCoreService.save(from);
        return RestResultBuilder.builder().success().data(save).build();
    }
    @ApiOperation(value = "删除机构", notes = "删除机构")
    @RequestMapping(value = "/del",method = RequestMethod.POST)
    public RestResult<Boolean> del(@RequestBody OrganizationFrom from){
        Boolean f = organizationCoreService.del(from);
        return RestResultBuilder.builder().success( ).data(f).build();
    }
    @ApiOperation(value = "停用机构", notes = "停用机构")
    @RequestMapping(value = "/ban",method = RequestMethod.POST)
    public RestResult<Integer> ban(@RequestBody OrganizationFrom from){
        Integer f = organizationCoreService.ban(from);
        return RestResultBuilder.builder().success().data(f).build();
    }
}
